package cn.liontalk.concurrent.readwritelock;


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class ReadWriteLockDemo {

    public static void main(String[] args) {

        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();

        Lock write = readWriteLock.writeLock();

        Lock read = readWriteLock.readLock();

        write.lock();
        System.out.println("I am write lock");


        read.lock();
        System.out.println("I am read lock");

    }
}
